package com.itany.interptor;

import com.itany.pojo.ManagerUser;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Interceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
       ManagerUser user = (ManagerUser)request.getSession().getAttribute("User");
       if (null == user){
           response.sendRedirect("/manager/showLogin");
           return false;
       }
        return true;
    }

}
